package com.liws.hellopoi.commons;

import lombok.Data;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: liweisheng
 * @Dcscription:
 * @Date: 2022/1/27 15:02
 */
@Data
public class ResponseVo {

    private Object errCode;
    private String errMsg;

    private static Map<String, Object> successMap;
    private static Map<String, Object> errMap;

    static {
        successMap = new HashMap<String, Object>();
        errMap = new HashMap<String, Object>();
        successMap.put("code", 200);
        successMap.put("chs", "成功");
        successMap.put("eng", "success");

        errMap.put("code", 500);
        errMap.put("chs", "失败");
        errMap.put("eng", "fail");
    }

    private ResponseVo(){

    }

    private ResponseVo(Object errCode,String errMsg){
        this.errCode=errCode;
        this.errMsg=errMsg;
    }

    public static ResponseVo succeed(String errMsg){

        return new ResponseVo(successMap,errMsg);
    }

    public static ResponseVo fail(String errMsg){

        return new ResponseVo(errMap,errMsg);
    }
}
